package guda.shop.cms.manager.impl;

import guda.shop.cms.dao.ShopDictionaryDao;
import guda.shop.cms.entity.ShopDictionary;
import guda.shop.cms.manager.ShopDictionaryMng;
import guda.shop.common.hibernate3.Updater;
import guda.shop.common.page.Pagination;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class ShopDictionaryMngImpl
        implements ShopDictionaryMng {
    private ShopDictionaryDao shopDictionaryDao;

    @Transactional(readOnly = true)
    public Pagination getPage(int paramInt1, int paramInt2) {
        Pagination localPagination = this.shopDictionaryDao.getPage(paramInt1, paramInt2);
        return localPagination;
    }

    public Pagination getPage(String paramString, Long paramLong, int paramInt1, int paramInt2) {
        Pagination localPagination = this.shopDictionaryDao.getPage(paramString, paramLong, paramInt1, paramInt2);
        return localPagination;
    }

    @Transactional(readOnly = true)
    public ShopDictionary findById(Long paramLong) {
        ShopDictionary localShopDictionary = this.shopDictionaryDao.findById(paramLong);
        return localShopDictionary;
    }

    public List<ShopDictionary> getListByType(Long paramLong) {
        return this.shopDictionaryDao.getListByType(paramLong);
    }

    public ShopDictionary save(ShopDictionary paramShopDictionary) {
        this.shopDictionaryDao.save(paramShopDictionary);
        return paramShopDictionary;
    }

    public ShopDictionary update(ShopDictionary paramShopDictionary) {
        Updater localUpdater = new Updater(paramShopDictionary);
        ShopDictionary localShopDictionary = this.shopDictionaryDao.updateByUpdater(localUpdater);
        return localShopDictionary;
    }

    public ShopDictionary deleteById(Long paramLong) {
        ShopDictionary localShopDictionary = this.shopDictionaryDao.deleteById(paramLong);
        return localShopDictionary;
    }

    public ShopDictionary[] deleteByIds(Long[] paramArrayOfLong) {
        ShopDictionary[] arrayOfShopDictionary = new ShopDictionary[paramArrayOfLong.length];
        int i = 0;
        int j = paramArrayOfLong.length;
        while (i < j) {
            arrayOfShopDictionary[i] = deleteById(paramArrayOfLong[i]);
            i++;
        }
        return arrayOfShopDictionary;
    }

    public ShopDictionary[] updatePriority(Long[] paramArrayOfLong, Integer[] paramArrayOfInteger) {
        int i = paramArrayOfLong.length;
        ShopDictionary[] arrayOfShopDictionary = new ShopDictionary[i];
        for (int j = 0; j < i; j++) {
            arrayOfShopDictionary[j] = findById(paramArrayOfLong[j]);
            arrayOfShopDictionary[j].setPriority(paramArrayOfInteger[j]);
        }
        return arrayOfShopDictionary;
    }

    @Autowired
    public void setDao(ShopDictionaryDao paramShopDictionaryDao) {
        this.shopDictionaryDao = paramShopDictionaryDao;
    }
}

